package com.cjkj.system.controller;

import com.cjkj.common.core.constant.EquipmentConstants;
import com.cjkj.common.core.exception.ServiceException;
import com.cjkj.common.core.web.domain.AjaxResult;
import com.cjkj.common.core.web.page.TableDataInfo;
import com.cjkj.system.api.domain.request.EquipmentHistoryReq;
import com.cjkj.system.api.domain.request.RecordsReq;
import com.cjkj.system.domain.dto.HourlyDataReq;
import com.cjkj.system.domain.dto.TJ02ReportsDataReq;
import com.cjkj.system.service.ReportTJ02Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 多参数监测仪监测报告控制器
 */
@RestController
@RequestMapping("reports/tj02")
public class ReportTJ02Controller {

    @Resource
    private ReportTJ02Service reportTJ02Service;

    /**
     * 体测报告-体温
     * @param req
     * @return
     */
    @GetMapping("/temperature")
    public AjaxResult temperatureReports(RecordsReq req){
        if(req.getVisitNo() == null){
            throw new ServiceException("就诊号不能为空！");
        }
        return AjaxResult.success(reportTJ02Service.getTJ02TemperatureReports(req.getVisitNo()));
}

    /**
     * 体测报告-血氧
     * @param req
     * @return
     */
    @GetMapping("/spO2")
    public AjaxResult spO2Reports(RecordsReq req){
        if(req.getVisitNo() == null){
            throw new ServiceException("就诊号不能为空！");
        }
        return AjaxResult.success(reportTJ02Service.getTJ02SpO2Reports(req.getVisitNo()));
    }

    /**
     * 体测报告-脉率
     * @param req
     * @return
     */
    @GetMapping("/heartRate")
    public AjaxResult heartRateReports(RecordsReq req){
        if(req.getVisitNo() == null){
            throw new ServiceException("就诊号不能为空！");
        }
        return AjaxResult.success(reportTJ02Service.getTJ02HeartRateReports(req.getVisitNo()));
    }

    /**
     * 获取患者监测报告
     * @return
     */
    @GetMapping("getPatientReportData")
    public AjaxResult getPatientReportData(@Valid TJ02ReportsDataReq req) {
        return AjaxResult.success(reportTJ02Service.getPatientReportData(req));
    }

    /**
     * 患者虚拟报告数据生成
     * @param req
     * @return
     */
    @GetMapping("virtualReportDataGeneration")
    public AjaxResult virtualReportDataGeneration(@Valid TJ02ReportsDataReq req) {
        return AjaxResult.success(reportTJ02Service.virtualReportDataGeneration(req));
    }

    /**
     * 获取整点护理数据
     * 03:00,07:00,11:00,15:00,19:00,23:00六个时间点
     * @return
     */
    @GetMapping("/hourlyData")
    public TableDataInfo getHourlyData(HourlyDataReq req){
        return reportTJ02Service.getHourlyData(req);
    }

    /**
     * 获取历史记录
     * @return
     */
    @GetMapping("/historyData")
    public AjaxResult patVisit(@Valid EquipmentHistoryReq req){
        req.setEquipmentType(EquipmentConstants.EQUIPMENT_TYPE_SMART_BRACELET_TYPE);
        return reportTJ02Service.getBraceletHistoryData(req);
    }
}
